#ifndef CUSTOMBUTTON_H
#define CUSTOMBUTTON_H

#include "yspushbutton.h"

#include <QPushButton>
#include <QPainter>
#include <QStyleOption>
#include <QEnterEvent>
#include <QButtonGroup>

class CustomButton : public YSPushButton
{
    Q_OBJECT
    Q_PROPERTY(int btnType READ btnType WRITE setBtnType)

public:
    enum BtnType{
        TEXT_ICON_UP,//文字图标在上
        ICON_CENTER  //只有图标
    };
    explicit CustomButton(QWidget *parent = nullptr);
    void setGroup(QButtonGroup* group);
    QPixmap getBackgroundImage() const;
    QColor getTextColor() const;
    int btnType();
    void setBtnType(int nType);
protected:
    void paintEvent(QPaintEvent *event) override;
    void mousePressEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;
private:
    bool m_isPressed;     // 是否处于按下状态
    QButtonGroup *m_group;
    QPixmap m_normalPixmap;
    QPixmap m_nselectPixmap;
    int m_nBtnType=TEXT_ICON_UP;
};

#endif // CUSTOMBUTTON_H 
